<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <title>Hello Spring Security</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="/css/main.css" th:href="@{/css/main.css}" />
</head>
<body>
<div th:fragment="logout" class="logout">

    <form name='f' th:action='@{/login}' method='POST'>
        <table>
            <tr><td>User:</td><td>
                <input type='text' name='username' value='' /></td></tr>
            <tr><td>Password:</td>
                <td><input type='password' name='password'/></td></tr>
            <tr><td colspan='2'>
                <input id="remember_me" name="remember-me" type="checkbox"/>
                <label for="remember_me" class="inline">Remember me</label></td></tr>
            <tr><td colspan='2'>
                <input name="submit" type="submit" value="Login"/></td></tr>
        </table>
    </form>

    <hr/>

    <div sec:authorize="isAuthenticated()">
        登录用户: <span sec:authentication="name"></span> |
        角色: <span sec:authentication="principal.authorities"></span>
        <div>
            <form action="#" th:action="@{/logout}" method="post">
                <input type="submit" value="Logout" />
            </form>
        </div>
    </div>
</div>
<h1>Hello Spring Security</h1>
<p>This is an unsecured page, but you can access the secured pages after authenticating.</p>
<ul>
    <li>Go to the <a href="/user/index" th:href="@{/user/index}">secured pages</a></li>
</ul>
</body>
</html>